var attendIndexCtrl = myApp.controller('attendIndexCtrl', ['$scope', '$rootScope', function($scope, $rootScope) {
	$rootScope.firstType = Tools.permissionList[2].permissionId;
	$rootScope.secondType = Tools.permissionList[2].sonPermission[0].permissionId;
	// 初始化
	function init() {
		$(document).ready(function() {
			setEchart1();
			setEchart2();
		});
	}
	init();

	// 柱状图-本日出勤情况
	function setEchart1() {
		var echart = document.getElementById('echart1');
		var myChart = echarts.init(echart);
		var option = {
			tooltip: {
				trigger: 'axis',
				type: 'shadow'
			},
			legend: {
				data: ['未设置', '正常出勤', '考勤异常']
			},
			grid: {
			    left: '3%',
		        right: '4%',
		        bottom: '3%',
		        containLabel: true
		    },
		    xAxis: [
		        {
		            type : 'category',
		            data : ['小一班', '小二班', '中一班', '中二班', '大班'],
		            axisTick: {
		                alignWithLabel: true
		            }
		        }
		    ],
		    yAxis: [
		        {
		            type : 'value'
		        }
		    ],
		    series : [
		        {
		            name:'未设置',
		            type:'bar',
		            data:[20, 24, 32, 38, 39]
		        }, {
		        	name:'正常出勤',
		            type:'bar',
		            data:[22, 27, 33, 32, 39]
		        }, {
		        	name:'考勤异常',
		            type:'bar',
		            data:[3, 1, 3, 4, 0]
		        }
		    ]
		};
		myChart.setOption(option);
	}

	// 饼图-园所症状分析
	function setEchart2 () {
		var echart = document.getElementById('echart2');
		var myChart = echarts.init(echart);
		var option = {
		    tooltip : {
		        trigger: 'item',
		        formatter: "{a} <br/> {b} : {d}%"
		    },
		    legend: {
		        orient: 'vertical',
		        left: 'left',
		        top: 'center',
		        data: ['发热','流鼻涕','咳嗽','腹泻','咽喉发炎', '指甲过长', '红眼病', '呕吐', '皮疹', '黄疸', '疑似传染病', '其他']
		    },
		    series : [
		        {
		            name: '年龄分布',
		            type: 'pie',
		            radius : '55%',
		            center: ['50%', '60%'],
		            data:[
		                {value:335, name:'发热'},
		                {value:310, name:'流鼻涕'},
		                {value:234, name:'咳嗽'},
		                {value:135, name:'腹泻'},
		                {value:800, name:'咽喉发炎'},
		                {value:135, name:'指甲过长'},
		                {value:800, name:'红眼病'},
		                {value:135, name:'呕吐'},
		                {value:800, name:'皮疹'},
		                {value:135, name:'黄疸'},
		                {value:800, name:'疑似传染病'},
		                {value:123, name:'其他'}
		            ],
		            itemStyle: {
		                emphasis: {
		                    shadowBlur: 10,
		                    shadowOffsetX: 0,
		                    shadowColor: 'rgba(0, 0, 0, 0.5)'
		                }
		            }
		        }
		    ]
		}
		myChart.setOption(option);
	}
}]);